<template>
  <div>
    <div class="page-title">关于我们</div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="内容">
        <el-input type="textarea" v-model="form.content"></el-input>


      </el-form-item>
      <el-form-item>
        <el-button type="success" icon="el-icon-check" @click="submit">添加</el-button>
        <el-button icon="el-icon-close" @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {
  request_about_find,
  request_about_update,
} from '@/util/api'

export default {
  name: 'AddManager',
  data() {
    return {
      form: {
        id:0,
        content: '',
      },
      branchs: []
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.$nextTick(() => {
        request_about_find()
            .then((res) => {
              const result = res.data;
              if (result.code == 200) {
                this.form.content = result.data.content;
                this.form.id = result.data.id;
              }
            })
            .catch();
      });
    },
    // 提交
    submit() {
      if (this.form.content == '') {
        this.$notify.info({
          title: '系统提示',
          message: '请输入内容',
          offset: 70
        })
        return false
      }

      request_about_update(this.form).then(res => {
        const result = res.data
        if (result.code == 200) {
          this.$notify.success({
            title: '系统提示',
            message: '修改成功',
            offset: 70
          })
          this.$router.push('/about_us')
        }
      }).catch()
    },
    // 取消
    cancel() {
      this.$router.push('/about_us')
    }
  }
}
</script>

<style>
</style>